var fileManager = Class.create();
fileManager.prototype = {
    root_path: null, // upload root path ex. /uploads/xanhte_file_manager/3 (3 is user_id)
    root_url : null, // XOOPS_ROOT_URL
    file_path: null, // useful value ex. 3/user/create/to/path

  initialize: function(root_path, root_url, file_path){
      this.root_path = root_path; /// root_path is not terminated by '/'.
      this.root_url  = root_url;
      this.file_path = file_path; /// file_path is done trim(file_path, '/') by PHP
  },


  removeFile: function(filename,ximg){
      if (!confirm('Remove Really?')){
          return null;
      }
      var ajax = new Ajax.Request(
          './file_manager.php',{
            method: 'post',
            parameters: 'action_xanhte_filemanager_remove=1&file_name='+filename+'&file_path='+this.file_path,
            requestHeaders: ['Referer', location.href],
            onSuccess: function(httpobj,json){
                Element.hide(ximg.parentNode);
            }
          });
  },

  fileSelect: function(filename,is_thumb){
      var swap_path = this.root_url+this.root_path;
      swap_path += this.file_path ? '/'+this.file_path : '';
      swap_path += is_thumb==true ? '/thumbnail/' : '/';
      swap_path += filename;
      //let our opener know what we want
      window.opener.my_win.document.getElementById(window.opener.my_field).value = swap_path;
      window.opener.my_win.document.getElementById(window.opener.my_field).onchange();
      //we close ourself, cause we don't need us anymore ;)
      window.close();
  }
};
